<script type="text/javascript">

$(function(){
	$.get("inventorymanagement/getCardInfo",function(data){
		var contentb="<option value='' selected>请选择</option>";
		var i;
		$(data).each(function(n,item){
			for(i=0;i<item.cdProDefinitions.length;i++){
				
				contentb+="<option value="+item.cdProDefinitions[i].cardpCode+">"
				+item.cdProDefinitions[i].cardpName+"</option>"
			}
			$("#CardCode").html(contentb);
		});
	},"json");
	
	$.get("inventorymanagement/parseTaskParams",parseTaskParams,"json");
})

//添加任务
/* $("#addDisTassk").click(function(){
	var $obj = $(this);
	var options = new Object();
	var data = new Object();
	//获取选择的数据的validStatus值
	//var param ="";
	console.log("此事件的对象是==>"+$obj.prop("outerHTML"));
//	var $htmlObject = $obj.prop("outerHTML");
    var branchNo = $("input[name='branchNo']").val();
	var rel = $obj.attr("rel");
	var max = $obj.attr("max");
	var title = encodeURI($obj.attr("title"));
	console.log("a标签中的内容==>"+rel+"#"+max+"#"+title);
//	options.rel = rel;
//	options.max = max;
//	options.title = title;
//	alert("titel==>"+options.title);
	
	var paramArray = "";
	
	//获取按钮是启用还是停用
//	var buttonParam = $obj.attr("param");
//	alert("buttonParam==>"+buttonParam);
	
	if($("input[name='distributionTasks']:checked").length < 1){
		 alertMsg.warn("您未选择数据！");
		 return false;
	}
	if($("input[name='distributionTasks']:checked").length>=1){
		$("input[name='distributionTasks']:checked").each(function(n,item){
			if(n==0){
				paramArray=$(this).val();
			}else{
				paramArray = paramArray + "$"	+$(this).val();	
			}
			
		});	
		console.log("被选中的参数==>"+paramArray);
		data.checkedItems = paramArray;
		data.branchNo = branchNo;
		options.data = data;
		console.log("网点编号是==>"+options.data.branchNo);
		console.log("被选中的项目有==>"+options.data.checkedItems);
		
		
	}
	// 打开ajax请求，处理数据，将勾选住的信息，制作成一个txt文档
	// options中既有选中的item项，还有a标签中的任何属性和属性值
	//$.post("inventorymanagement/createDistributeTaskFile",options,openDialog,"json");
	//$.pdialog.open("inventorymanagement/createDistributeTaskFile",rel,title,options);
	 navTab.openTab("ditributeTask","inventorymanagement/createDistributeTaskFile",options);
	
})  */



//查询按钮绑定事件,查询前，将所有分页信息清空
$("#queryRejectCardInfo").click(function(){
	$("input[name='currentPage']").val("");
	$("input[name='numPerPage']").val("");
	$("input[name='pageCount']").val("");
	var citizenCardNo = $("input[name='citizenCardNo']").val();
	console.log("citizenCardNo===>"+citizenCardNo.length);
	if(citizenCardNo){
		if(citizenCardNo.length!=12){
			alertMsg.warn("请输入长度为12的卡号！");
			return false;
		}
		if(!/^[0-9]{12}$/.test(citizenCardNo)){
			alertMsg.warn("请输入长度为12位的数字！");
			return false;
		}
	}
})

//刷新每页数量
function paging(){
	var numPerPage=$("#numPerPageByproduct").val();
	$("input[name='numPerPage']").val(numPerPage);
	var parm=$("#getCardProduct").serialize();
	$.post("parameterCard/getCardProductD",parm, getCardProductD,"json")
};
//下一页
function next(){
	var currentPage=$("input[name='currentPage']").val();
	$("input[name='currentPage']").val(parseInt(currentPage)+1);
	var parm=$("#getCardProduct").serialize();
	$.post("parameterCard/getCardProductD",parm,getCardProductD,"json");
};

//上一页
function previous(){
	var currentPage=$("input[name='currentPage']").val();
	$("input[name='currentPage']").val(parseInt(currentPage)-1);
	var parm=$("#getCardProduct").serialize();
	$.post("parameterCard/getCardProductD",parm,getCardProductD,"json");
};	
//删除信息
function deleteProduct(){
	if($("input[name='producttasked']:checked").length < 1){
		 alertMsg.warn("您未选择数据！")
		 return false;
	 }
	var parm="";
	var array;
	$("input[name='producttasked']:checked").each(function(n,item){
		array=$(this).val().split(",");
		parm+=array[0]+","
	})
	var numPerPage=$("#numPerPageByproduct").val();
	var currentPage=$("input[name='currentPage']").val();
	var pageCount=$("input[name='pageCount']").val();
	$("input[name='numPerPage']").val(numPerPage); 
	var html_cardTypeCode = $("#cardTypeCodeByQuery").val();
	var html_cardpCode = $("#cardpCodeByQuery").val();
	//$.post("parameterCard/deleteProduct",{numPerPage:numPerPage,currentPage:currentPage,parm:parm,pageCount:pageCount}, getCardProductD,"json");
	$.post("parameterCard/deleteProduct",{numPerPage:numPerPage,cardTCode:html_cardTypeCode,
		currentPage:currentPage,pageCount:pageCount,cardPCode:html_cardpCode,parm:parm}, getCardProductD,"json");
}	
function validateCheckBox(obj){
	 
	var $obj = $(obj);
	//获取选择的数据的validStatus值
	if($("input[name='distributionTasks']:checked").length < 1){
		 alertMsg.warn("您未选择数据！")	
		 return false;
	}
}
</script>
<div class="pageHeader ">
	<form method="post" action="inventorymanagement/queryDIstributeCardInfo" class="pageForm required-validate" onsubmit="return validateCallback(this,queryDIstributeCardInfo);">
		<input type="hidden" name="currentPage" value="" /> 
		<input type="hidden" name="numPerPage" value="" />
		<input type="hidden" name="pageCount" value="" />
		<div class="searchBar">	
		 <table class="searchContent">
			<tr>
				<td><label>卡号：</label></td>
				<td><input  name="citizenCardNo"  class="" type="text" size="20"  value=""/></td>
			</tr>
			<tr>
				<td><label>卡产品名称：</label></td>
				<td><select id="CardCode" name="CardCode" >
				</select></td>
			</tr>
			<tr>
				<td><label>起始日期：</label></td>
				<td><input  name="fromDate" class="" type="text" size="20"  value=""/></td>
			</tr>
			<tr>
				<td><label>终止日期：</label></td>
				<td><input  name="toDate" class="" type="text" size="20"  value=""/></td>
			</tr>
			
			</table>
			<input  name="branchNo" class="" type="hidden"  value=""/>
			
			<input  name="empNo" class="" type="hidden"  value="" />
			
			<input  name="cardControlIdList" class="" type="hidden" value="" />
		<div class="subBar">
			<ul> 
				<li>
				<div class="buttonActive" ><div class="buttonContent" ><button id="queryRejectCardInfo" type="submit">查询</button></div></div>
				</li>
			</ul>
		</div>
	 </div>
	 
	</form>
</div>
<form method="post" action="inventorymanagement/createDistributeTaskFile" class="pageForm required-validate" onsubmit="return validateCallback(this,dialogAjaxDone);" >	
	 <div class="pageContent" >
		<input id="branchNoByCreateDis" name="branchNoByCreateDis" type="hidden" value="">
		<input id="empNoByCreateDis" name="empNoByCreateDis" type="hidden" value="">	
		<input id="taskNoByCreateDis" name="taskNoByCreateDis" type="hidden" value="">	
	</div>
	<!-- <input name="producttasked" type="checkbox" style="display:none" value="xxxxxxxxxxx" checked> -->
		<div id="tocreatedis">
		<table class="table" width="800" layoutH="388">
			<thead>
				<tr>
					<th width="5%" align="center"><input type="checkbox" name="producttaskedTotal" group="producttasked" class="checkboxCtrl"></th>
					<th width="8%" align="center">序号</th>				
					<th width="15%" align="center">卡号</th>
					<th width="15%" align="center">卡产品名称</th>
					<th width="15%" align="center">卡片有效标志</th>
					<th width="10%" align="center">制卡商</th>
					<th width="20%" align="center">配送原因</th>	
					<th width="0%" align="center" style="display:none;">卡产品代码</th>
					<th width="0%" align="center" style="display:none;">制卡商代码</th>
					<th width="0%" align="center" style="display:none;">配送原因代码</th>
					<th width="0%" align="center" style="display:none;">卡控制ID</th>
				</tr>
			</thead>
			<tbody id="distributeTasks">
				
			</tbody>
		</table>
		</div>
	<div class="panelBar">
		<div class="pages">
			<span>显示</span>
			<select id="numPerPageByproduct" name="numPerPage" onchange="paging()">
				<option value="10">10</option>
				<option value="20">20</option>
				<option value="50">50</option>
				<option value="100">100</option>
			</select>
			<span id="totalCountByProduct"></span>
		</div>
			<div id="paginationByProduct" class="pagination1"  ></div>
	</div>

		<div class="formBar">
			<ul> 
				<!-- <li>
					<div class="buttonActive" ><div class="buttonContent" >
					<button id="available" type="submit" onclick="return validateCheckBox(this);" >添加到配送任务</button></div></div>
				</li> -->
				<li>
				    <div class="buttonActive" ><div class="buttonContent" >
					<button id="addDisTassk" type="submit" onclick="return validateCheckBox(this);" >添加到配送任务</button></div></div>
				</li>
				<li>
					<div class="buttonActive" ><div class="buttonContent" >
					<button class="close">关闭</button></div></div>
				</li>
			</ul>
		</div> 
	
</div>
	</form>